package com.xingkeduo.business.user.service;

import com.xingkeduo.business.user.dao.ConsumerStatisticsPushMapper;
import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.ConsumerStatisticsQO;
import com.xingkeduo.pojo.table.ConsumerStatisticsTO;
import com.xingkeduo.util.tool.CommonUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/2/22 19:01
 **/
@Service
public class ConsumerStatisticsService {

    private static final String NAMESPACE = CommonUtil.formatNamespace(ConsumerStatisticsTO.class);
    @Resource(name = "mysqlUserMasterDao")
    private DatabaseAccessObject<ConsumerStatisticsTO, ConsumerStatisticsQO> dao;

    @Resource
    private ConsumerStatisticsPushMapper consumerStatisticsPushMapper;

    public List<ConsumerStatisticsTO> selectConsumerForList(ConsumerStatisticsQO statisticsQO) throws Throwable {
        return dao.select(NAMESPACE, statisticsQO);
    }

    /**
     * 查询id集合
     *
     * @param statisticsQO:
     * @return : java.util.List<java.lang.Long>
     * @author : gaozifeng
     * @date : 2019/3/1 16:55
     */
    public List<Long> selectUserPrivateForId(ConsumerStatisticsQO statisticsQO) throws Throwable {
        return dao.selectIndex(NAMESPACE, statisticsQO);
    }

    /**
     * 查询主键
     *
     * @param id:
     * @return : com.xingkeduo.pojo.table.ConsumerStatisticsTO
     * @author : gaozifeng
     * @date : 2019/3/14 17:22
     */
    public ConsumerStatisticsTO selectByPrimary(long id) throws Throwable {
        return dao.select(NAMESPACE, id);
    }

    /**
     * 新增
     *
     * @param consumerStatisticsTO:
     * @return : int
     * @author : gaozifeng
     * @date : 2019/3/14 17:24
     */
    public int insert(ConsumerStatisticsTO consumerStatisticsTO) throws Throwable {
        return dao.insert(NAMESPACE, consumerStatisticsTO);
    }

    /**
     * 修改
     *
     * @param consumerStatisticsTO:
     * @return : int
     * @author : gaozifeng
     * @date : 2019/3/14 17:24
     */
    public int update(ConsumerStatisticsTO consumerStatisticsTO) throws Throwable {
        return dao.update(NAMESPACE, consumerStatisticsTO);
    }

    public List<Long> selectUserListId(ConsumerStatisticsQO consumerStatisticsQO) {
        return consumerStatisticsPushMapper.selectUserListId(consumerStatisticsQO);
    }
}
